package com.pro.api;

import com.pro.VO.CourseInfo_page;
import com.pro.bean.Courseinfo;
import com.pro.bean.PageGoods;
import com.pro.dto.Dto;
import com.pro.service.*;
import com.pro.util.dtoUtil.DtoUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("cousrseinfo")
public class AdminCourseinfoController {
    @Autowired
    private CourseinfoService courseinfoService;

    @Autowired
    private CourseAVInfoService courseAVInfoService;

    @Autowired
    private CourseCategoryService courseCategoryService;

    @Autowired
    private MentorService mentorService;

    /****
     * 查询所有课程信息
     *
     */
    @GetMapping("list")
    public Dto selAll(PageGoods page){
        List<Courseinfo> courseinfos =courseinfoService.selAll(page);//分页后的课程信息
        int total = courseinfoService.courseCount();//课程总数
        return DtoUtil.returnSuccess(new CourseInfo_page(courseinfos,total));
    }

    /***
     * 查询课程详情目录
     */
    @GetMapping("goodsDetail")
    public Dto goodsDetail(int courseinfoId){
        return DtoUtil.returnSuccess(courseAVInfoService.selA_VInfoById(courseinfoId));
    }

    /***
     * 查询当前项目中所有分类
     */
     @GetMapping("category")
     public Dto category(){
         return DtoUtil.returnSuccess(courseCategoryService.listCategory());
     }

    /***
     * 查询所有讲师
     */
    @GetMapping("allMentor")
    public Dto allMentor(){
        return DtoUtil.returnSuccess(mentorService.selMentor());
    }

}
